<template>
  <div>
    <div id="r-1">
      <div id="song">
        <el-table :data="list.slice((currentPage-1)*pageSize, currentPage*pageSize)" border style="width: 100%" lazy>
          <el-table-column prop="date" width="180">
          </el-table-column>
          <el-table-column prop="name" label="歌曲名称" width="180">
          </el-table-column>
          <el-table-column prop="address" label="歌手"></el-table-column>
          <el-table-column>
            <ul>
              <li>播放</li>
              <li>查看</li>
            </ul>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
       <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount"
    ></el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1, // 当前显示页
      pageSize: 10, // 每页显示数据条数
      pageSizes: [5, 10,15, 30], // 可选择每页显示数据条数
      totalCount: 10, // 数据总数
     list: [
        {
          date: "0",
           name: "我爱你",
          address: "很喜欢画画"
        },  {
          date: "1",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "2",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "3",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "4",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "5",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "6",
           name: "我爱你",
          address: "很喜欢画画"
        }, {
          date: "7",
           name: "我爱你",
          address: "很喜欢画画"
        },
      ], // 存放数据的数组
      
    };
  },
  methods: {
     GetPlaylist: function () {
      var thisvue = this;
      this.$http
        .get("http://localhost:31551/api/Playlist/GetPlaylist/")
        .then(function (res) {
          thisvue.Playlists = res.data;
        });
    },
    handleSizeChange(val) {
      // 每次切换页面大小时，此方法响应，改变页面大小
      this.pageSize = val;
      this.currentPage = 1; // 改变页面大小后，跳转回第一页
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      // 每次切面当前页时，此方法响应，改变当前页
      this.currentPage = val;
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style>
#song ul  li {
  float: left;
  margin-left: 25px;
}
.el-pagination{
  margin-left:70px;
  margin-top: 15px;
}
</style>
